const { letDataToJsFile, getPropsStr, getDefaultModelDataStr, getSlotHtmlStr } = require("./_utils");

const defaultOptions = {
  description: "描述：暂无",
  withProps: true,
  defaultValue: { id: 0, nc: "这是用户昵称", zy: 0, xm: "" },
};

module.exports = {
  getFormStr(fields = [], options) {
    const { description, withProps, defaultValue } = { ...defaultOptions, ...options };
    const defValStr = getDefaultModelDataStr(defaultValue);
    return `<!-- ${description} -->
<template>
  <BaseForm${defValStr ? ' v-model="modelData"' : ""} :fields="fields">
    ${getSlotHtmlStr(fields)}
  </BaseForm>
</template>
<script lang="ts" setup>
import { ref, reactive, watch, computed } from "vue";
${getPropsStr(withProps)};
${defValStr}
const fields = ${letDataToJsFile(fields)};
</script>
<style lang="scss" scoped></style>`;
  },
};
